home *** CD-ROM | disk | FTP | other *** search
/ Aminet 32 / Aminet 32 (1999)(Schatztruhe)[!][Aug 1999].iso / Aminet / dev / lang / Python151_Src.lha / Python1.5_Source / Modules / timingmodule.c < prev    next >
C/C++ Source or Header  |  1998-12-24  |  1KB  |  90 lines

  1. /*
  2.  * Author: George V. Neville-Neil
  3.  */
  4.  
  5. #include "Python.h"
  6.  
  7. /* Our stuff... */
  8. #include "timing.h"
  9.  
  10. #include "protos/timingmodule_protos.h"
  11.  
  12. static PyObject *
  13. start_timing(self, args)
  14.     PyObject *self;
  15.     PyObject *args;
  16. {
  17.     if (!PyArg_Parse(args, ""))
  18.         return NULL;
  19.  
  20.     Py_INCREF(Py_None);
  21.     BEGINTIMING;
  22.     return Py_None;
  23. }
  24.  
  25. static PyObject *
  26. finish_timing(self, args)
  27.     PyObject *self;
  28.     PyObject *args;
  29. {
  30.     if (!PyArg_Parse(args, ""))
  31.         return NULL;
  32.  
  33.     ENDTIMING    
  34.     Py_INCREF(Py_None);
  35.     return Py_None;
  36. }
  37.  
  38. static PyObject *
  39. seconds(self, args)
  40.     PyObject *self;
  41.     PyObject *args;
  42. {
  43.     if (!PyArg_Parse(args, ""))
  44.         return NULL;
  45.  
  46.     return PyInt_FromLong(TIMINGS);
  47.  
  48. }
  49.  
  50. static PyObject *
  51. milli(self, args)
  52.     PyObject *self;
  53.     PyObject *args;
  54. {
  55.     if (!PyArg_Parse(args, ""))
  56.         return NULL;
  57.  
  58.     return PyInt_FromLong(TIMINGMS);
  59.  
  60. }
  61. static PyObject *
  62. micro(self, args)
  63.     PyObject *self;
  64.     PyObject *args;
  65. {
  66.     if (!PyArg_Parse(args, ""))
  67.         return NULL;
  68.  
  69.     return PyInt_FromLong(TIMINGUS);
  70.  
  71. }
  72.  
  73.  
  74. static PyMethodDef timing_methods[] = {
  75.     {"start",   start_timing},
  76.     {"finish",  finish_timing},
  77.     {"seconds", seconds},
  78.     {"milli",   milli},
  79.     {"micro",   micro},
  80.     {NULL,      NULL}
  81. };
  82.  
  83.  
  84. void inittiming()
  85. {
  86.     (void)Py_InitModule("timing", timing_methods);
  87.     if (PyErr_Occurred())
  88.         Py_FatalError("can't initialize module timing");
  89. }
  90.